package com.sikaryofficial.backend.controller;

import com.sikaryofficial.backend.domain.dto.req.brandspecial.BrandSpecialReq;
import com.sikaryofficial.backend.domain.dto.resp.brandspecial.BrandSpecialDTO;
import com.sikaryofficial.backend.manager.BrandSpecialManager;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.common.core.web.controller.BaseController;
import com.sikaryofficial.common.log.annotation.Log;
import com.sikaryofficial.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 品牌专栏Controller
 *
 * @author qinjinyuan
 * @date 2024-05-14
 */
@RestController
@RequestMapping("/brandSpecial/backend")
@Api(tags = "V2.5 后台-品牌专栏")
public class BrandSpecialBackendController extends BaseController {
    @Autowired
    private BrandSpecialManager brandSpecialManager;

    /**
     * 查询品牌专栏列表
     */
    @PostMapping("/list")
    @ApiOperation("后台-品牌专栏列表")
    public R<List<BrandSpecialDTO>> list() {
        return R.ok(brandSpecialManager.list());
    }

    /**
     * 获取品牌专栏详细信息
     */
    @GetMapping(value = "/detail/{brandSpecialId}")
    @ApiOperation("后台-品牌专栏详细")
    public R<BrandSpecialDTO> getInfo(@PathVariable("brandSpecialId") Long brandSpecialId) {
        return R.ok(brandSpecialManager.getInfo(brandSpecialId));
    }

    /**
     * 新增品牌专栏
     */
    @Log(title = "新增品牌专栏", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    @ApiOperation("新增品牌专栏")
    public R<Long> saveOrUpdate(@RequestBody BrandSpecialReq req) {
        return R.ok(brandSpecialManager.saveOrUpdate(req));
    }

    /**
     * 删除品牌专栏
     */
    @Log(title = "删除品牌专栏", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{brandSpecialIds}")
    @ApiOperation("删除品牌专栏")
    public R<Boolean> remove(
            @ApiParam(value = "brandSpecialIds 多个英文逗号分隔")
            @PathVariable String brandSpecialIds) {
        return R.ok(brandSpecialManager.remove(brandSpecialIds));
    }
}
